<?php

/**
 * 类的覆盖 或 重写
 */

class Notify
{
    protected $credit = 10;

    public function message()
    {
        return '发送消息' . ',奖励积分' . $this->credit();
    }

    public function credit()
    {
        return $this->credit;
    }
}

class User extends Notify
{
    protected $credit = 20;

    public function register()
    {
        return $this->message();
    }

    public function credit()
    {
        return 5;
    }
}

class Comment extends Notify
{
    public function send()
    {
        return $this->message();
    }
}

echo (new User)->register(); // 发送消息,奖励积分5
echo (new Comment)->send(); // 发送消息,奖励积分10